package com.itttq.sc;

import java.nio.charset.Charset;
import java.util.List;

import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;

public class GenericApplication extends WebMvcConfigurerAdapter {
//	@Bean
//    public HttpMessageConverters fastJsonConverters(){
//        FastJsonHttpMessageConverter fastJsonConverter = new FastJsonHttpMessageConverter();
//        FastJsonConfig fastConf = new FastJsonConfig();
//        
//        fastConf.setSerializerFeatures(SerializerFeature.PrettyFormat);
//        fastJsonConverter.setFastJsonConfig(fastConf);
//        
//        HttpMessageConverter<?> converter = fastJsonConverter;
//        return new HttpMessageConverters(converter);
//    }
	
	@Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        super.configureMessageConverters(converters);
        
        FastJsonHttpMessageConverter fastJsonConverter = new FastJsonHttpMessageConverter();
        FastJsonConfig fastConf = new FastJsonConfig();
        
        fastConf.setSerializerFeatures(SerializerFeature.PrettyFormat);
        fastJsonConverter.setFastJsonConfig(fastConf);
        fastConf.setCharset(Charset.forName("UTF-8"));
        fastJsonConverter.setFastJsonConfig(fastConf);
        
        converters.add(fastJsonConverter);
    }
}
